package com.chinasi.web.action;

import java.util.HashMap;
import java.util.Map;

import javax.naming.InsufficientResourcesException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.caland.framework.core.utils.ResponseUtils;
import com.caland.framework.core.utils.codehaus.json.JsonUtils;
import com.chinasi.model.ConsumerBasic;
import com.chinasi.model.IndustryInfo;
import com.chinasi.model.ProjectInfo;
import com.chinasi.service.BidBasicService;
import com.chinasi.service.IndustryInfoService;
import com.chinasi.service.ProjectInfoService;
import com.chinasi.web.action.common.DictCache;
import com.chinasi.web.action.common.URLConstants;

/**
 * 行业动态
 * @author xzl
 *
 */
@Controller
@RequestMapping(value = URLConstants.INFO)
public class IndustryInfoAction {

	@Autowired
	private BidBasicService wowBidBasicService;
	
	@Autowired
	private IndustryInfoService industryInfoService;
	
	@Autowired
	private ProjectInfoService projectService;
	
	/** 资讯分页列表 */
	@RequestMapping("list")
	public ModelAndView list(String tag){
		Map<String,Object> model = new HashMap<String, Object>();
		
		//项目列表
		model.put("bidList", wowBidBasicService.findPage(1));
		
		//行业资讯
		IndustryInfo industryInfoSearchBean = new IndustryInfo();
		industryInfoSearchBean.setInfoTag(tag);
		model.put("infoList", industryInfoService.findPageCondition(industryInfoSearchBean,1));
		
		//解决方案
		ProjectInfo projectInfoSearchBean = new ProjectInfo();
//		projectInfoSearchBean.setProjTag(tag);
		model.put("projectList", projectService.findPageCondition(projectInfoSearchBean,1));
		
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("tag", tag);
		model.put("params", params);
		
		model.put("menu", "HYZX");
		
		return new ModelAndView("/hydt/list", model);
	}
	
	/** 异步加载分页数据 */
	@RequestMapping("loadajax")
	public ModelAndView loadajax(HttpServletRequest request, HttpServletResponse response,IndustryInfo searchBean, int curpage){
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("pager", industryInfoService.findPageCondition(searchBean,curpage));
		return new ModelAndView("fragment/fragment_info_more", model);
	}
	
	/** 资讯分页列表 */
	@RequestMapping("detail")
	public ModelAndView detail(String id){
		Map<String,Object> model = new HashMap<String, Object>();
		
		//咨询信息
		model.put("info", industryInfoService.findById(id));
		
		//项目列表
		model.put("bidList", wowBidBasicService.findPage(1));
		
		//可能感兴趣
		model.put("interestInfoList", industryInfoService.findPageCondition(new IndustryInfo(),1));
		
		model.put("params", new IndustryInfo());
		
		return new ModelAndView("/hydt/info", model);
	}
}
